package cn.demo.cm.service.impl;

import java.util.List;
import com.mybatisflex.core.paginate.Page;
import cn.demo.common.core.page.PageQuery;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import cn.demo.cm.mapper.CmCarouselImgMapper;
import cn.demo.cm.domain.CmCarouselImg;
import cn.demo.cm.service.ICmCarouselImgService;

/**
 * 轮播图Service业务层处理
 *
 * @author xtjun
 * @date 2024-06-06
 */
@Service
public class CmCarouselImgServiceImpl extends ServiceImpl<CmCarouselImgMapper, CmCarouselImg> implements ICmCarouselImgService {
    @Resource
    private CmCarouselImgMapper cmCarouselImgMapper;
    /**
     * 查询轮播图
     *
     * @param id 轮播图主键
     * @return 轮播图
     */
    @Override
    public CmCarouselImg selectCmCarouselImgById(String id) {
        return cmCarouselImgMapper.selectOneById(id);
    }

    /**
     * 查询轮播图列表
     *
     * @param cmCarouselImg 轮播图
     * @return 轮播图
     */
    @Override
    public Page<CmCarouselImg> selectCmCarouselImgPage(CmCarouselImg cmCarouselImg, PageQuery pageQuery) {
        return cmCarouselImgMapper.paginate(pageQuery.build(), QueryWrapper.create(cmCarouselImg,CmCarouselImg.operators));
    }
    @Override
    public List<CmCarouselImg> selectCmCarouselImgList(CmCarouselImg cmCarouselImg) {
        return cmCarouselImgMapper.selectListByQuery(QueryWrapper.create(cmCarouselImg,CmCarouselImg.operators));
    }

    /**
     * 新增轮播图
     *
     * @param cmCarouselImg 轮播图
     * @return 结果
     */
    @Override
    public int insertCmCarouselImg(CmCarouselImg cmCarouselImg) {
        return cmCarouselImgMapper.insert(cmCarouselImg);
    }

    /**
     * 修改轮播图
     *
     * @param cmCarouselImg 轮播图
     * @return 结果
     */
    @Override
    public int updateCmCarouselImg(CmCarouselImg cmCarouselImg) {
        return cmCarouselImgMapper.update(cmCarouselImg);
    }

    /**
     * 批量删除轮播图
     *
     * @param ids 需要删除的轮播图主键
     * @return 结果
     */
    @Override
    public int deleteCmCarouselImgByIds(List<String> ids) {
        return cmCarouselImgMapper.deleteBatchByIds(ids);
    }

    /**
     * 删除轮播图信息
     *
     * @param id 轮播图主键
     * @return 结果
     */
    @Override
    public int deleteCmCarouselImgById(String id) {
        return cmCarouselImgMapper.deleteById(id);
    }
}
